import 'package:flutter/material.dart';

class GirdCase extends StatelessWidget {
  const GirdCase({Key? key}) : super(key: key);

  List<Widget> getChildren() {
    return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((int value) {
      return Container(
        alignment: Alignment.center,
        color: Colors.teal,
        child: Text(
          '第${value}个',
          style: TextStyle(color: Colors.white, fontSize: 30),
        ),
      );
    }).toList();
  }

  @override
  Widget build(BuildContext context) {
    return Padding(
        padding: const EdgeInsets.all(10),
        child: GridView(
          gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2, // 每行显示的列数
            mainAxisSpacing: 10, // 主轴方向的间距
            crossAxisSpacing: 10, // 交叉轴方向的间距
            childAspectRatio: 1.0, // 子元素的宽高比
          ),
          children: getChildren(),
        ));
  }
}
